# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#   
#   cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
#   Major.create(:name => 'Daley', :city => cities.first)

puts "Seeding the database with default values"

# Default Locations
uw = Location.create({
    :name    => 'UW Medical Center',
    :address => '1959 NE Pacific St., Seattle, WA 98195'
})


# Default Users
admin = User.create({ 
  :real_name        => 'Default Admin',
  :account_name     => 'admin',
  :password         => 'password',
  :email            => 'admin@linkedlst.com',
  :location         => uw,
  :permission_level => 'admin'
})


# Default Item Types
bag = ItemType.create({ 
  :item_type => 'Bag',
  :is_container => true 
})

box = ItemType.create({
  :item_type => 'Box', 
  :is_container => true
})

specimen = ItemType.create({
  :item_type => 'Specimen',
  :is_container => false
})


# Default Attribute Sets and Attributes
# Transport Conditions
transport_conditions = ItemAttributeSet.create({
  :name => 'Transport Conditions',
  :required => true,
  :inherits_from_container => true,
  :mutually_exclusive => true
})

transport_conditions.item_attributes.create(
  ['Frozen', 'Refrigerated', 'Room Temperature'].map {|x| { :display_text => x } } )


# Color
color = ItemAttributeSet.create({
  :name => 'Color',
  :mutually_exclusive => true
})

color.item_attributes.create([
  { :display_text => 'Red',     :display_color => '#FF0000' },
  { :display_text => 'Green',   :display_color => '#00AD00' },
  { :display_text => 'Blue',    :display_color => '#0000FF' },
  { :display_text => 'Purple',  :display_color => '#660066' },
  { :display_text => 'Black',   :display_color => '#000000' },
])


# Other Attributes
other = ItemAttributeSet.create({
  :name => 'Other Attributes',
  :mutually_exclusive => false
})

other.item_attributes.create([
  { :display_text => 'Irreplacable',    :verify_on_scan => true },
  { :display_text => 'Time-Sensitive',  :verify_on_scan => true },
])